package com.zxx.ssm.model.enums;

/**
 * Created by zxx on 2016/11/27.
 */
public enum ResultCode {
    //basic code
    SUCCESS("SUCCESS", "操作成功"),
    SYSTEM_FAILURE("SYSTEM_FAILURE", "系统错误"),
    NOT_SUPPORT("NOT_SUPPORT", "系统不支持该功能"),
    NULL_ARGUMENT("NULL_ARGUMENT", "参数为空"),
    ILLEGAL_ARGUMENT("ILLEGAL_ARGUMENT", "参数不正确"),
    IO_FAILURE("IO_FAILURE", "IO错误"),
    PARTIAL_FAILURE("PARTIAL_FAILURE", "部分失败"),
    ADMIN_LOGIN_ERROR("ADMIN_LOGIN_ERROR", "账号或密码错误"),

    //排课
    TEA_STU_CLASS_ERROR("TEA_STU_CLASS_ERROR", "排课操作失败"),
    TEA_STU_CLASS_DELETE_ERROR("TEA_STU_CLASS_DELETE_ERROR", "删除课程失败");


    private String value;
    private String message;

    ResultCode(String value, String message) {
        this.value = value;
        this.message = message;
    }

    /**
     * 根据枚举值获取枚举对象，如果找不到对应的枚举返回null
     *
     * @param value
     * @return
     */
    public static ResultCode getEnumByValue(String value) {
        for (ResultCode resultCode : ResultCode.values()) {
            if (resultCode.getValue().equals(value))
                return resultCode;
        }
        return null;
    }

    public String getValue() {
        return value;
    }

    public String getMessage() {
        return message;
    }
}
